<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>FCKTools.CreateEventListener</title>
	<style type="text/css">

		.Ok
		{
			background-color: green ;
		}

		.Failed
		{
			background-color: red ;
		}

		input
		{
			width: 150px;
		}

	</style>
	<script type="text/javascript">
var FCK = new Object() ;	// Used by fckconfig
	</script>
	<script src="../../../editor/_source/fckjscoreextensions.js" type="text/javascript"></script>
	<script src="../../../editor/_source/internals/fckbrowserinfo.js" type="text/javascript"></script>
	<script src="../../../editor/_source/classes/fckiecleanup.js" type="text/javascript"></script>
	<script src="../../../editor/_source/internals/fcktools.js" type="text/javascript"></script>
	<script type="text/javascript">

function LoadScript( url )
{
	document.write( '<script type="text/javascript" src="' + url + '"><\/script>' ) ;
}
var sSuffix = FCKBrowserInfo.IsIE ? 'ie' : 'gecko' ;
LoadScript( '../../../editor/_source/internals/fcktools_' + sSuffix + '.js' ) ;

	</script>
	<script type="text/javascript">

if ( FCKBrowserInfo.IsIE )
	FCK.IECleanup = new FCKIECleanup( window ) ;

FCKTools.RegisterDollarFunction( window ) ;

var oFirerObject = new Object() ;
var oFirerElement = new Object() ;
var oFirerObjectParams = new Object() ;
var oFirerElementParams = new Object() ;

window.onload = function()
{
	oFirerObject.OnEvent		= FCKTools.CreateEventListener( OnObject, [ 'Test', 10 ] ) ;
	oFirerElement.OnEvent		= FCKTools.CreateEventListener( OnElement, document.body ) ;
	oFirerObjectParams.OnEvent	= FCKTools.CreateEventListener( OnObjectParams, [ 'Test', 10 ] ) ;
	oFirerElementParams.OnEvent	= FCKTools.CreateEventListener( OnElementParams, document.body ) ;
}

function OnObject( str, num )
{
	$('xObject').className = ( str == 'Test' && num == 10 ? 'Ok' : 'Failed' ) ;
}

function OnElement( el )
{
	$('xElement').className = ( el.tagName == 'BODY' ? 'Ok' : 'Failed' ) ;
}

function OnObjectParams( btn, evStr, str, num )
{
	$('xObjectParams').className = ( btn.id == 'xBtnObjectParams' && evStr == 'Test' && str == 'Test' && num == 10 ? 'Ok' : 'Failed' ) ;
}

function OnElementParams( btn, evStr, el )
{
	$('xElementParams').className = ( btn.id == 'xBtnElementParams' && evStr == 'Test' && el.tagName == 'BODY' ? 'Ok' : 'Failed' ) ;
}

	</script>
</head>
<body>
	<h1>
		FCKTools.CreateEventListener</h1>
	<p>
		Click the following buttons. A green box must appear at their right side.
	</p>
	<table align="center">
		<tr>
			<td>
				<input id="xBtnObject" type="button" value="Object" onclick="oFirerObject.OnEvent();" /></td>
			<td id="xObject" width="100">
			</td>
		</tr>
		<tr>
			<td>
				<input id="xBtnElement" type="button" value="Element" onclick="oFirerElement.OnEvent();" /></td>
			<td id="xElement" width="100">
			</td>
		</tr>
		<tr>
			<td>
				<input id="xBtnObjectParams" type="button" value="Object + Params" onclick="oFirerObjectParams.OnEvent( this, 'Test' );" /></td>
			<td id="xObjectParams" width="100">
			</td>
		</tr>
		<tr>
			<td>
				<input id="xBtnElementParams" type="button" value="Element + Params" onclick="oFirerElementParams.OnEvent( this, 'Test' );" /></td>
			<td id="xElementParams" width="100">
			</td>
		</tr>
	</table>
</body>
</html>
